import React, {Component} from 'react';
import {Link} from 'react-router-dom'

class Goods extends Component {
    componentDidMount() {
        console.log(this.props.history)
    }

    render() {
        return (
            <div>
                <button onClick={this.goRutern}>使用go返回-可以指定返回几个页面</button>
                <br/>
                <button onClick={this.goBack}>使用goBack返回</button>
                <br/>
                <Link to={"/"}>去首页</Link><br/>
                <button onClick={this.goForward}>前进</button>
                <br/>
            </div>
        );
    }
    goRutern = ()=>{
        this.props.history.go(-1)
    }
    goBack = ()=>{
        this.props.history.goBack()
    }
    goForward = ()=>{
        this.props.history.goForward()
    }

}

export default Goods;